package com.homegoods.classify.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.homegoods.classify.R;
import com.homegoods.classify.model.RightModel;

import java.util.List;

/**
 * add shibo.zheng
 * 19/06/21
 * 分类其他数据展示的adapter
 * （临时adapter使用方案）
 */
public class ZPOtherAdapter extends RecyclerView.Adapter<ZPOtherAdapter.OtherViewHolder> {
    private Context mContext;
    private List<RightModel> rightModels;

    public ZPOtherAdapter(Context mContext, List<RightModel> rightModels) {
        this.mContext = mContext;
        this.rightModels = rightModels;
    }

    @Override
    public OtherViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.classify_other_item, parent, false);
        OtherViewHolder otherViewHolder = new OtherViewHolder(view);
        return otherViewHolder;
    }

    @Override
    public void onBindViewHolder(OtherViewHolder holder, int position) {
        holder.otherImg.setImageResource(rightModels.get(position).getRightImg());
        holder.otherText.setText(rightModels.get(position).getRightText());

    }

    @Override
    public int getItemCount() {
        return rightModels.size();
    }

    public class OtherViewHolder extends RecyclerView.ViewHolder {
        private ImageView otherImg;
        private TextView otherText;

        public OtherViewHolder(View itemView) {
            super(itemView);
            otherImg = itemView.findViewById(R.id.other_img);
            otherText = itemView.findViewById(R.id.other_text);
        }
    }

}
